# -*- coding:utf-8 -*-

import pandas as pd


def quarter_volume():
    data = pd.read_csv('apple.csv', header=0)

    '''
    补充代码：
    1. 使用 Pandas 选择数据
    2. 转换为时间序列
    3. 按季度重采样并排序
    '''
    data.index = pd.to_datetime(data['Date'])
    d = data.resample('Q').sum().sort_values(by='Volume', ascending=False)
    second_volume = d.iloc[1]['Volume']
    # = d.index[1]
    return second_volume


if __name__=='__main__':
    print(quarter_volume())

# wget http://labfile.oss.aliyuncs.com/courses/1013/week7/ClimateChange.xlsx
# challenge7_1.py